clear;
clear_temp_folder

iter_num = 1000; % data size per test group
% iter_num = 64; % data size per test group
para_num = 1; % test group number
% epsilon = 0.00001;
% save('parameters.mat','iter_num','para_num','epsilon');

parfor j=1:para_num*iter_num
    [data(j).bfu, data(j).l1_norm, data(j).convergence,data(j).step] = runparallelcode_adaptive(j);
end

% for j=1:para_num*iter_num
%     [data(j).bfu, data(j).l1_norm, data(j).convergence] = runparallelcode(j);
% end


% j = 1;
% [data(j).angle, data(j).beta, data(j).c_0, data(j).h, data(j).bfu, data(j).bfx, data(j).l1_norm, data(j).convergence] = runparallelcode(j);


% norm_list_temp = [];
% k_sum_list_temp = 0;
% success_count_temp = 0;
% results = zeros(para_num,4);

% for j = 1:para_num*iter_num
% 
%     if data(j).final_obj <= epsilon
%         norm_list_temp = [norm_list_temp;data(j).final_norm];
%         k_sum_list_temp = k_sum_list_temp + data(j).k_final;
%         success_count_temp = success_count_temp + 1;
%     end
% 
%     if mod(j,iter_num)==0
%         results(j/iter_num,1) = data(j).var;                        %variable parameter
%         results(j/iter_num,2) = k_sum_list_temp/success_count_temp; %average k_end
%         results(j/iter_num,3) = mean(norm_list_temp);               %average l1 norm of solutions
%         results(j/iter_num,4) = min_with_nan(norm_list_temp);       %minimum l1 norm found in solutions
%         l1_norm_list(j/iter_num).data = norm_list_temp;
%         norm_list_temp = [];
%         k_sum_list_temp = 0;
%         success_count_temp = 0;
%     end
% 
% end

clear epsilon j k_sum_list_temp norm_list_temp para_num success_count_temp iter_num

save("./matfiles/"+ string(datestr(datetime(),'mmddHHMM')))

play_sound